﻿using Abp.Authorization;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using FwProject.Settlement;
using System;
using System.Collections.Generic;
using System.Text;

namespace FwProject.Sms
{
    /// <summary>
    /// 过期服务不在使用
    /// </summary>
    [Obsolete]
    public class SmsAppService : FwProjectAppServiceBase, ISmsAppService
    {
        static String product = "Dysmsapi";//短信API产品名称
        static String domain = "dysmsapi.aliyuncs.com";//短信API产品域名
        static String accessId = "LTAIzps6sDvXpScJ";
        static String accessSecret = "u6I6GIbqD2TpGHCSiCd9rNa1SbZaNT";
        static String regionIdForPop = "cn-hangzhou";
        public void SendIdentifyingCode(string tel, string code)
        {
            IClientProfile clientProfile = DefaultProfile.GetProfile(regionIdForPop, accessId, accessSecret);
            DefaultProfile.AddEndpoint(regionIdForPop, regionIdForPop, "Dysmsapi", "dysmsapi.aliyuncs.com");
            IAcsClient acsClient = new DefaultAcsClient(clientProfile);
            
           
            try
            {
                //SendSmsRequest request = new SendSmsRequest();
                //request.PhoneNumbers = tel;
                //request.SignName = "饭碗易购";
                //request.TemplateCode = "SMS_134317672";
                //request.TemplateParam = "{\"code\":\""+code+"\"}";

                ////请求失败这里会抛ClientException异常
                //var   sendSmsResponse = acsClient.GetAcsResponse(request);
                //System.Console.WriteLine(sendSmsResponse.Message);

            }
            catch (ServerException e)
            {
                System.Console.WriteLine($"ServerException:{e.ToString()}");
            }
            catch (ClientException e)
            {
                System.Console.WriteLine($"ClientException:{e.ToString()}");
            }
        }


     
    }
}
